/**
 * @author: h'zh
 * @date: 12.14
 */

//TODO:适配各种向后端发出的请求(用户操作)
//============ 与 student student 组相关的api ================
import request from '../utils/request'

export function getUserStudentByUsername(username){
    return request({
            url: '/student/getUserStudentByUsername/' + username,
            method: 'get'
        }
    )
}

export function getStudentByStudentId(studentId)
{
    return request({
        url:'/student/getStudentByStudentId/' + studentId,
        method:'get'
    })
}

export function getGoodList() {
    return request({
        url: '/student/getGoodList',
        method: 'get'
    })
}

//得到全部的request
export function  getAllRequest()
{
    return request({
        url:'/student/getAllRequests',
        method:'get',
    })
}

//得到全部的商品
export function  getAllGoods()
{
    return request({
        url:'/student/getAllGoods',
        method:'get',
    })
}

export function getRequestList() {
    return request({
        url: '/student/getRequestList',
        method: 'get'
    })
}

export function modifyStudent(studentId, name, sex, address, qq, tel) {
    return request({
        url: '/student/modifyStudent',
        method: 'post',
        data: {
            studentId,
            name,
            sex,
            address,
            qq,
            tel
        }
    });
}

export function addRequest(studentId, requestName, requestType, price, description) {
    return request({
        url: '/student/addRequest',
        method: 'post',
        data: {
            studentId,
            requestName,
            requestType,
            price,
            description
        }
    });
}

export function addGood(studentId, goodName, goodType, price, description) {
    return request({
        url: '/student/addGood',
        method: 'post',
        data: {
            studentId,
            goodName,
            goodType,
            price,
            description
        }
    });
}

export function modifyGood(goodId, goodName, goodType, price, description, isSold) {
    return request({
        url: '/student/modifyGood',
        method: 'post',
        data: {
            goodId,
            goodName,
            goodType,
            price,
            description,
            isSold
        }
    });
}

export function deleteGood(id){
    return request({
            url: '/student/deleteGood/' + id,
            method: 'post'
        }
    )
}

export function modifyRequest(requestId, requestName, requestType, price, description) {
    return request({
        url: '/student/modifyRequest',
        method: 'post',
        data: {
            requestId,
            requestName,
            requestType,
            price,
            description
        }
    });
}

export function getTestResult(params) {
    return request({
        url: '/group/getTestResult',
        method: 'get',
        params
    })
}

export function getTestResultOfHtml(xmlid) {
    return request({
        url: `/group/getTestDetail/${xmlid}`,
        method: 'get'
    })
}

export function getScriptDetail(xmlid) {
    return request({
        url: `/group/getScriptDetail/${xmlid}`,
        method: 'get'
    })
}

export function updateGroupTestStatus() {
    return request({
        url: '/group/updateGroupTestStatus',
        method: 'get'
    })
}

export function getGroupTestStatus() {
    return request({
        url: '/group/getGroupTestStatus',
        method: 'get'
    })
}

export function getCodeProcessStatus() {
    return request({
        url: '/group/getCodeProcessStatus',
        method: 'get'
    })
}

export function initGroupTestStatus() {
    return request({
        url: '/group/initGroupTestStatus',
        method: 'get'
    })
}

export function getAllModuleByGroup() {
    return request({
        url: '/hustbase/getAllModuleByGroup',
        method: 'get'
    })
}

export function moduleGroupTest(moduleId) {
    return request({
        url: '/hustbase/groupTest/' + moduleId,
        method: 'get'
    })
}

export function scriptGroupTest(xmlid) {
    return request({
        url: '/hustbase/groupTestByScript/' + xmlid,
        method: 'get'
    })
}

export function allModuleTest() {
    return request({
        url: '/hustbase/allModuleTest',
        method: 'get'
    })
}

export function findTestResultsOfGroup(groupId){
    return request({
        url: '/group/getGroupTestStatus/'+ groupId,
        method: 'get'
      }
    )
}

export function updateGroupTestScore(groupId,testScore){
    return request({
        url: 'group/updateGroupTestScore',
        method: 'post',
        data:{
            groupId: groupId,
            testScore: testScore,
            teacherScore: 0,
            note:''
        }
    })
}

export function updateGroupTeacherScore(groupId,teacherScore,note){
    return request({
        url: 'group/updateGroupTeacherScore',
        method: 'post',
        data:{
            groupId: groupId,
            testScore: 0 ,
            teacherScore: teacherScore,
            note: note
        }
    })
}

export function findUserGroupByUsername(username){
    return request({
            url: '/group/getUserGroupByUsername/'+ username,
            method: 'get'
        }
    )
}

export function findAllGroupOfTeacherForGroup(userTeacherId, term){
    return request({
        url: 'group/findAllGroupOfTeacherForGroup/'+userTeacherId+'/'+term,
        method: 'get'
    })
}
